package com.unicom.office.node;

import com.sun.org.apache.xpath.internal.operations.Bool;
import com.unicom.office.func.FuncCommon;
import com.unicom.office.type.TextRangeTypeItem;
import com.unicom.office.type.TypeItem;
import com.unicom.office.func.FuncBase;
import com.unicom.office.unit.OfficeUnit;
import com.unicom.office.unit.TextRangeUnit;

public class TextRangeNode extends OfficeNode {
    private String text;
    private Boolean isNumeric;
    private OfficeTextStype textStype;

    public TextRangeNode(Object source) {
        super(source);
        this.textStype = new OfficeTextStype();
    }

    public OfficeNode clone() {
        TextRangeNode textRangeNode = new TextRangeNode(getSource());
        textRangeNode.text = text;
        return textRangeNode;
    }

    public OfficeUnit createUnit() {
        TextRangeUnit textRangeUnit = new TextRangeUnit();
        textRangeUnit.setText(this.text, isNumeric);
        return textRangeUnit;
    }

    public boolean testChildType(FuncCommon child) {
        return false;
    }

    public String getText() {
        return text;
    }

    public Boolean getIsNumeric() {
        return this.isNumeric;
    }

    public void setText(String text, Boolean isNumeric) {
        this.text = text;
        this.isNumeric = isNumeric;
    }

    public void setText(char c, Boolean isNumeric){
        this.text = String.valueOf(c);
        this.isNumeric = isNumeric;
    }

    public void appendText(String text) {
        this.text += text;
    }

    public void appendChar(char c){
        this.text += c;
    }

    public OfficeTextStype getTextStype() {
        return textStype;
    }

    public void setTextStype(OfficeTextStype textStype) {
        this.textStype = textStype;
    }

    public String toString(){
        return getText();
    }

    public boolean testChildType(OfficeNode child) {
        return false;
    }

    public TypeItem getType() {
        return TextRangeTypeItem.INSTANCE;
    }
}
